<?php
/**
 * @author sunjing@shopex.cn
 * @describe 订单种类二进制常量类
 */

class ome_order_bool_type {
    #是否是服务订单
    const __GIFT_CODE        = 0x0400;
   #风控订单
    const __RISK_CODE        = 0x2000;
    
    private $boolStatus = array(
        self::__GIFT_CODE => array('identifier'=>'赠', 'text'=>'赠品订单', 'color'=>'pink','search'=>'true'),
        self::__RISK_CODE => array('identifier'=>'风', 'text'=>'风控订单', 'color'=>'#E438A0', 'search'=>'true'),
       
    );


    public function getBoolTypeText($num = null) {
        if($num) {
            return (array) $this->boolStatus[$num];
        }
        return $this->boolStatus;
    }

    public function getBoolTypeIdentifier($boolType) {
        $str = '';
        foreach($this->boolStatus as $k => $val) {
            if($boolType & $k) {
                $str .= sprintf("<span class='tag-label' title='%s' style='background-color:%s;color:#000000;'>%s</span>", $val['text'], $val['color'], $val['identifier']);
            }
        }
        return $str;
    }

    
    
    public function getOrder_type_list(){
        $order_type_list = array();
        $boolstatus = $this->boolStatus;
        foreach($boolstatus as $k=>$v){
            if ($v['search'] == 'true'){
                $order_type_list[$k]= $v['text'];
            }
        }
        return $order_type_list;
    }
    
    /**
     * 获取订单种类文字描述
     */
    public function getBoolTypeDescribe($boolType){
        $data = array();
        foreach($this->boolStatus as $k => $val) {
            if($boolType & $k) {
                $data[] = $val['text'];
            }
        }
        
        return implode('、', $data);
    }
}
